#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <set>
using namespace std;
class Solution
{
public:
    // f(n) 表示从a[0]到a[n]中最长上升子序列的长度
    // f(n) = max f(i) + 1 其中0<=i<n 且 a[i] < a[n]
    int lengthOfLIS(vector<int> &nums)
    {
        int ret = INT32_MIN;
        if (nums.size() == 0)
            return 0;
        vector<int> f(nums.size(), 1);
        for (int i = 0; i < f.size(); ++i)
        {
            int cmp = INT32_MIN;
            for (int j = 0; j < i; ++j)
            {
                if (nums[j] < nums[i])
                    cmp = max(cmp, f[j]);
            }
            if (cmp > INT32_MIN)
                f[i] = cmp + 1;
            ret = max(ret, f[i]);
        }
        return ret;
    }
};